﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SonCa.SocialNetwork.Web.Friends.IPresenters;
using SonCa.SocialNetwork.Web.Friends.Presenters;
using SonCa.SocialNetwork.Web.ASCX;
using Core.DataAccess;
using SonCa.SocialNetwork.Web.HelperClass;

namespace SonCa.SocialNetwork.Web.Friends
{
    public partial class DisplayAllFriend : System.Web.UI.Page, IAllFriendsPresenter
    {
        private AllFriendsPresenter _presenter;

        protected void Page_Load(object sender, EventArgs e)
        {
            _presenter = new AllFriendsPresenter();
            _presenter.Init(this);
        }

        public void LoadAllFriend(List<HelperClass.FriendRequestHelper> friendRquestHelpers)
        {            
            DisplayAllProfile dpAll = new DisplayAllProfile();
            dpAll.GetInfo();
            rptAllFriend.DataSource = friendRquestHelpers;
            rptAllFriend.DataBind();
        }

        protected void rptAllFriend_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DisplayAllProfile ucDisplayAllProfile = e.Item.FindControl("pdDisplayAllProfile") as DisplayAllProfile;
                ucDisplayAllProfile.LoadAllDisplay((FriendRequestHelper)e.Item.DataItem);
            }
        }
    }
}